#include <cstdio>
#include <cstring>

int main( )
{
    int t, i, l, n;
    char str[ 40 ];
    scanf("%d", &t);
    while ( t-- )
    {
        scanf("%s%d", str, &n);
        l = strlen( str );
        for ( i = 0; i < l; i++ )
            if ( str[ i ] == '.' )
                break;
        if ( i == l )
        {
            puts("0");
            continue;
        }
        if ( i + n >= l )
            puts("0");
        else
            printf("%c\n", str[ i + n ]);
    }
    return 0;
}
